package top.kaoshanji.p2ch15b;

/**
 * 代码清单-p2ch15b-455页b：协作对象FireFlag
 * author kaoshanji
 * ^_^
 * create time 2025/2/24 17:05
 */
public class RacerFireFlag {

    private volatile boolean fired = false;

    public synchronized void waitForFire() throws InterruptedException {
        while (!fired) {
            wait();
        }
        System.out.println("现在条件满足..开始执行...");
    }

    public synchronized void fire() {
        this.fired = true;

        System.out.println("让条件满足..通知其他线程执行...");
        notifyAll();
    }


}
